//#if UNITY_EDITOR
#if UNITY_EDITOR
using Cysharp.Threading.Tasks;
using IQIGame.Onigao.Game;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay
{
    public class EntityExample
    {
        /// <summary>
        /// 直接从池里获取对象
        /// </summary>
        /// <returns></returns>
        public static async UniTask<Entity> ShowLevelEntity()
        {
            Entity entity = ManagerCenter.Entity.Get(PathConstant.GetEntityLevelPrefabPath("npc_NoblemanM001"), (int)EntityPoolGroupType.LevelEntity);
            await entity.Load();
            Debug.Log($"Entity: {entity.Id}, {entity.GetType()}, {entity.gameObject}");
            Debug.LogError("该方法为示例方法，请勿在实际业务代码中使用");
            return entity;
        }

        /// <summary>
        /// 从池里获取对象，并手动管理对象池分组
        /// 
        /// 需要自行管理分组时，记得在FrameworkExt预设里，找到Entity节点，找到该分组，并勾选DoNotAddOnInit
        /// </summary>
        /// <returns></returns>
        public static async UniTask<Entity> ShowLevelEntityManualManageGroup()
        {
            // 激活对象池
            ManagerCenter.Entity.EnableGroup((int)EntityPoolGroupType.LevelEntity);
            Entity entity = ManagerCenter.Entity.Get(PathConstant.GetEntityLevelPrefabPath("npc_NoblemanM001"), (int)EntityPoolGroupType.LevelEntity);
            EntityLoadState state = await entity.Load();
            Debug.Log($"Entity: {entity.Id}, {entity.GetType()}, {entity.gameObject}, LoadState：{state}");
            // 关闭对象池
            ManagerCenter.Entity.DisableGroup((int)EntityPoolGroupType.LevelEntity);
            Debug.LogError("该方法为示例方法，请勿在实际业务代码中使用");
            return entity;
        }
    }
}
#endif
//#endif UNITY_EDITOR